<script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import useUserStore from '@/store/user'
import dayjs from 'dayjs'

const userStore = useUserStore()
const today = dayjs().format('YYYY-MM-DD')

onLaunch((option) => {
  const { scene } = option.query
  const share_code = scene ? decodeURIComponent(scene).split('=')[1] : ''
  const { viewDuration, setShareCode } = userStore
  if (share_code) setShareCode(share_code)
  userStore.getSystemConfig()
  if (viewDuration.time !== today) {
    userStore.setViewDuration({
      time: today,
      duration: 0,
    })
  }
  console.log('App Launch')
})
onShow(() => {
  console.log('App Show')
})
onHide(() => {
  console.log('App Hide')
})
</script>

<style lang="scss">
@import '@zebra-ui/swiper/index';
/* #ifndef APP-NVUE */
::-webkit-scrollbar,
::-webkit-scrollbar,
::-webkit-scrollbar {
  display: none;
  width: 0 !important;
  height: 0 !important;
  -webkit-appearance: none;
  background: transparent;
}
/* #endif */
/* #ifdef H5 */
// 通过样式穿透，隐藏H5下，scroll-view下的滚动条
scroll-view ::v-deep ::-webkit-scrollbar {
  display: none;
  width: 0 !important;
  height: 0 !important;
  -webkit-appearance: none;
  background: transparent;
}
/* #endif */

.auto-img,
.auto-video {
  width: 100%;
}
/* stylelint-disable selector-type-no-unknown */
.wot-theme-light button {
  padding: 0;
  margin: 0;

  ::after {
    border: none;
  }
}

swiper,
scroll-view {
  flex: 1;
  height: 100%;
  overflow: hidden;
}

image {
  width: 100%;
  height: 100%;
  vertical-align: middle;
}

// 单行省略，优先使用 unocss: text-ellipsis
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// 两行省略
.ellipsis-2 {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

// 三行省略
.ellipsis-3 {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
</style>
